package com.qf.exc;

import org.springframework.web.servlet.HandlerExceptionResolver;
import org.springframework.web.servlet.ModelAndView;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author mkr
 * @version V1.0
 * @Project java2203-mkr
 * @Package com.qf.exc
 * @Description:
 * @Date 2022/6/9 21:40
 * 自定义异常处理器，项目中的所有异常问题都会汇集到这里进行处理
 */
public class MyExceptionResolver implements HandlerExceptionResolver {

    @Override
    public ModelAndView resolveException(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e) {
        //打印异常堆栈信息到日志
        e.printStackTrace();

        ModelAndView modelAndView = new ModelAndView();
        //返回给用户提示信息
        modelAndView.addObject("","抱歉!当前访问人数过多!请耐心等待!谢谢！！");
        //设置跳转页面
        modelAndView.setViewName("error1");
        return modelAndView;
    }
}
